package com.example.springbootexamples.jsch;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {

    @Test
    public void r(){

        try {
            ServerSocket serverSocket=new ServerSocket(8888);
            Socket socket=serverSocket.accept();

        InputStream inputStream= socket.getInputStream();
            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
            String l=bufferedReader.readLine();
            while(!"end".equals(l)){
                System.out.println(l);
                l=bufferedReader.readLine();
            }

            for(int i=0;i<1000;i++){
                System.out.println("sleep "+i);
                Thread.sleep(1000);
            }


        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }

}
